package com.jackiepenghe.huaweimqttlibrary

import android.util.Log
import com.jackiepenghe.huaweimqttlibrary.DebugUtil.LOG_LEVEL_OFF

object DebugUtil {

    const val LOG_LEVEL_OFF = 0
    const val LOG_LEVEL_DEBUG = 1
    const val LOG_LEVEL_INFO = 2
    const val LOG_LEVEL_WARNING = 3
    const val LOG_LEVEL_VERBOSE = 4

    private var logLevel = LOG_LEVEL_OFF

    fun setDebugLevel(logLevel: Int) {
        this.logLevel = logLevel
    }

    fun logOut(tag: String, msg: String) {
        when (logLevel) {
            LOG_LEVEL_DEBUG -> {
                Log.d(tag, msg)
            }
            LOG_LEVEL_INFO -> {
                Log.i(tag, msg)
            }
            LOG_LEVEL_WARNING -> {
                Log.w(tag, msg)
            }
            LOG_LEVEL_VERBOSE -> {
                Log.v(tag, msg)
            }
            LOG_LEVEL_OFF -> {
                //do nothing
            }
            else -> {

            }
        }
    }
}